#include "server.hpp"

int main(void)
{
    Socket client_sock;
    client_sock.CreateClient(8500, "127.0.0.1");
    while (true)
    {
        // 发送信息给server
        std::string str = "hello world";
        client_sock.Send(str.c_str(), str.size());

        // 从server获取返回信息
        char buffer[1024];
        client_sock.Recv(buffer, sizeof(buffer) - 1);
        buffer[strlen(buffer) - 1] = 0; // strlen(buffer) - 1 == 17, 没有这一句的话，会打印乱码的哦
        // buffer[sizeof(buffer) - 1] = 0;  sizeof(buffer) - 1 = 1023 这里用 sizeof 是有问题的哦
        DBG_LOG("buffer.size() = %d  %s", strlen("天气还不错!!!"), buffer);
        sleep(1);
    }

    return 0;
}